﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using MyMVCApplication.Validations;

namespace MyMVCApplication.Models
{
    public class Customer
    {
        [Required(ErrorMessage = "FirstName is required!")]
        public string FirstName { get; set; }

        [Required(ErrorMessage = "LastName is required!")]
        public string LastName { get; set; } 
    }

    //public class Customer  : IDataErrorInfo
    //{
    //    private string _firstName;
    //    private string _lastName; 
    //    private Dictionary<String,String> _errors = new Dictionary<string, string>();

        
    //    public string FirstName
    //    {
    //        get { return _firstName; }
    //        set
    //        {
    //            if(String.IsNullOrEmpty(value)) 
    //                _errors.Add("FirstName","FirstName cannot be blank!");

    //            _firstName = value; 
    //        }
    //    }

    //    public string LastName
    //    {
    //        get { return _lastName; }
    //        set
    //        {
    //            if(String.IsNullOrEmpty(value))        
    //                _errors.Add("LastName","LastName cannot be blank!");

    //            _lastName = value;
    //        }
    //    }
        
    //    public string this[string columnName]
    //    {
    //        get
    //        {
    //            if (_errors.ContainsKey(columnName))
    //                return _errors[columnName];

    //            return String.Empty;
    //        } 
    //    }

    //    public string Error
    //    {
    //        get { return String.Empty;  }
    //    }
    //}
}
